/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-

   credenza-window-info.h: Interface for credenza windows
 
   Copyright (C) 2004 Red Hat Inc.
  
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.
  
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
  
   You should have received a copy of the GNU General Public
   License along with this program; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
  
   Author: Alexander Larsson <alexl@redhat.com>
*/

#ifndef CREDENZA_WINDOW_INFO_H
#define CREDENZA_WINDOW_INFO_H

#include <glib-object.h>
#include <libcredenza-private/credenza-view.h>
#include <gtk/gtk.h>
#include "../src/credenza-bookmark-list.h"

G_BEGIN_DECLS

typedef enum
{
	CREDENZA_WINDOW_SHOW_HIDDEN_FILES_DEFAULT,
	CREDENZA_WINDOW_SHOW_HIDDEN_FILES_ENABLE,
	CREDENZA_WINDOW_SHOW_HIDDEN_FILES_DISABLE
} CredenzaWindowShowHiddenFilesMode;


typedef enum {
	CREDENZA_WINDOW_OPEN_ACCORDING_TO_MODE,
	CREDENZA_WINDOW_OPEN_IN_SPATIAL,
} CredenzaWindowOpenMode;

typedef enum {
	CREDENZA_WINDOW_OPEN_FLAG_CLOSE_BEHIND = 1<<0,
} CredenzaWindowOpenFlags;

typedef	enum {
	CREDENZA_WINDOW_SPATIAL,
	CREDENZA_WINDOW_DESKTOP
} CredenzaWindowType;

#define CREDENZA_TYPE_WINDOW_INFO           (credenza_window_info_get_type ())
#define CREDENZA_WINDOW_INFO(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), CREDENZA_TYPE_WINDOW_INFO, CredenzaWindowInfo))
#define CREDENZA_IS_WINDOW_INFO(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CREDENZA_TYPE_WINDOW_INFO))
#define CREDENZA_WINDOW_INFO_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CREDENZA_TYPE_WINDOW_INFO, CredenzaWindowInfoIface))

#ifndef CREDENZA_WINDOW_DEFINED
#define CREDENZA_WINDOW_DEFINED
/* Using CredenzaWindow for the vtable to make implementing this in 
 * CredenzaWindow easier */
typedef struct CredenzaWindow          CredenzaWindow;
#endif

#ifndef CREDENZA_WINDOW_SLOT_DEFINED
#define CREDENZA_WINDOW_SLOT_DEFINED
typedef struct CredenzaWindowSlot      CredenzaWindowSlot;
#endif


typedef CredenzaWindowSlot              CredenzaWindowSlotInfo;
typedef CredenzaWindow                  CredenzaWindowInfo;

typedef struct _CredenzaWindowInfoIface CredenzaWindowInfoIface;

struct _CredenzaWindowInfoIface 
{
	GTypeInterface g_iface;

	/* signals: */

        void           (* loading_uri)              (CredenzaWindowInfo *window,
						     const char        *uri);
	/* Emitted when the view in the window changes the selection */
        void           (* selection_changed)        (CredenzaWindowInfo *window);
        void           (* title_changed)            (CredenzaWindowInfo *window,
						     const char         *title);
        void           (* hidden_files_mode_changed)(CredenzaWindowInfo *window);
  
	/* VTable: */
	/* A view calls this once after a load_location, once it starts loading the
	 * directory. Might be called directly, or later on the mainloop.
	 * This can also be called at any other time if the view needs to
	 * re-load the location. But the view needs to call load_complete first if
	 * its currently loading. */
	void (* report_load_underway) (CredenzaWindowInfo *window,
				       CredenzaView *view);
	/* A view calls this once after reporting load_underway, when the location
	   has been fully loaded, or when the load was stopped
	   (by an error or by the user). */
	void (* report_load_complete) (CredenzaWindowInfo *window,
				       CredenzaView *view);
	/* This can be called at any time when there has been a catastrophic failure of
	   the view. It will result in the view being removed. */
	void (* report_view_failed)   (CredenzaWindowInfo *window,
				       CredenzaView *view);
	void (* report_selection_changed) (CredenzaWindowInfo *window);
	
	/* Returns the number of selected items in the view */	
	int  (* get_selection_count)  (CredenzaWindowInfo    *window);
	
	/* Returns a list of uris for th selected items in the view, caller frees it */	
	GList *(* get_selection)      (CredenzaWindowInfo    *window);

	char * (* get_current_location)  (CredenzaWindowInfo *window);
	void   (* push_status)           (CredenzaWindowInfo *window,
					  const char *status);
	char * (* get_title)             (CredenzaWindowInfo *window);
	GList *(* get_history)           (CredenzaWindowInfo *window);
	CredenzaWindowType
	       (* get_window_type)       (CredenzaWindowInfo *window);
	CredenzaWindowShowHiddenFilesMode
	       (* get_hidden_files_mode) (CredenzaWindowInfo *window);
	void   (* set_hidden_files_mode) (CredenzaWindowInfo *window,
				       CredenzaWindowShowHiddenFilesMode mode);

	CredenzaWindowSlotInfo * (* get_active_slot) (CredenzaWindowInfo *window);
	CredenzaWindowSlotInfo * (* get_extra_slot)  (CredenzaWindowInfo *window);

	gboolean (* get_initiated_unmount) (CredenzaWindowInfo *window);
	void   (* set_initiated_unmount) (CredenzaWindowInfo *window,
					  gboolean initiated_unmount);

	void   (* view_visible)        (CredenzaWindowInfo *window,
					CredenzaView *view);
	void   (* close_window)       (CredenzaWindowInfo *window);
	GtkUIManager *     (* get_ui_manager)   (CredenzaWindowInfo *window);
};

GType                             credenza_window_info_get_type                 (void);
void                              credenza_window_info_report_load_underway     (CredenzaWindowInfo                *window,
										 CredenzaView                      *view);
void                              credenza_window_info_report_load_complete     (CredenzaWindowInfo                *window,
										 CredenzaView                      *view);
void                              credenza_window_info_report_view_failed       (CredenzaWindowInfo                *window,
										 CredenzaView                      *view);
void                              credenza_window_info_report_selection_changed (CredenzaWindowInfo                *window);
CredenzaWindowSlotInfo *          credenza_window_info_get_active_slot          (CredenzaWindowInfo                *window);
CredenzaWindowSlotInfo *          credenza_window_info_get_extra_slot           (CredenzaWindowInfo                *window);
void                              credenza_window_info_view_visible             (CredenzaWindowInfo                *window,
										 CredenzaView                      *view);
void                              credenza_window_info_close                    (CredenzaWindowInfo                *window);
void                              credenza_window_info_push_status              (CredenzaWindowInfo                *window,
										 const char                        *status);
CredenzaWindowType                credenza_window_info_get_window_type          (CredenzaWindowInfo                *window);
char *                            credenza_window_info_get_title                (CredenzaWindowInfo                *window);
GList *                           credenza_window_info_get_history              (CredenzaWindowInfo                *window);
char *                            credenza_window_info_get_current_location     (CredenzaWindowInfo                *window);
int                               credenza_window_info_get_selection_count      (CredenzaWindowInfo                *window);
GList *                           credenza_window_info_get_selection            (CredenzaWindowInfo                *window);
CredenzaWindowShowHiddenFilesMode credenza_window_info_get_hidden_files_mode    (CredenzaWindowInfo                *window);
void                              credenza_window_info_set_hidden_files_mode    (CredenzaWindowInfo                *window,
										 CredenzaWindowShowHiddenFilesMode  mode);
gboolean                          credenza_window_info_get_initiated_unmount    (CredenzaWindowInfo                *window);
void                              credenza_window_info_set_initiated_unmount    (CredenzaWindowInfo                *window,
										 gboolean initiated_unmount);
GtkUIManager *                    credenza_window_info_get_ui_manager           (CredenzaWindowInfo                *window);

G_END_DECLS

#endif /* CREDENZA_WINDOW_INFO_H */
